home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / delphi1 / lesson4 / todolist / savemess.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-12  |  1.1 KB  |  51 lines

  1. unit Savemess;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls;
  8.   { Implements a message box to show that a file has been saved.
  9.     The duration of the box's display is controlled by a Timer
  10.     object }
  11.  
  12. type
  13.   TSaveMsg = class(TForm)
  14.     Timer1: TTimer;
  15.     MsgLabel: TLabel;
  16.     procedure Timer1Timer(Sender: TObject);
  17.     procedure FormShow(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   SaveMsg: TSaveMsg;
  26.  
  27. implementation
  28.  
  29. {$R *.DFM}
  30.  
  31. { Note this is called using ShowModal.
  32.   Since it has no buttons, it must be explicitly terminated
  33.   by setting its ModalResult property }
  34.  
  35. procedure TSaveMsg.Timer1Timer(Sender: TObject);
  36. begin
  37.   Timer1.Enabled := false;
  38.   ModalResult := mrOK;
  39.   Hide;
  40. end;
  41.  
  42. procedure TSaveMsg.FormShow(Sender: TObject);
  43. begin
  44.     ClientWidth := MsgLabel.Width;
  45.     { make sure the timer measures a full interval }
  46.     Timer1.Enabled := true;
  47.     Timer1.Interval := 1000; { 1 second }
  48. end;
  49.  
  50. end.
  51.